<template>
<HomePannel title="人气推荐" subTitle="人气爆款 不容错过">
    <template #main>
        <ul v-if="goodslist.length"  class="goods-list">
            <li v-for="item in goodslist" :key="item.id">
                <router-link :to="`/product/${item.id}`">
                    <img v-lazy="item.picture" alt="">
                    <p class="title">{{item.title}}</p>
                    <p>{{item.alt}}</p>
                </router-link>
            </li>
        </ul>
        <HomeSkeleton v-else/>
    </template>
</HomePannel>

</template>

<script>
import HomeSkeleton from './HomeSkeleton.vue'
import HomePannel from './HomePannel.vue'
import { getHotAPI } from '@/api/home'
import { ref } from 'vue'
export default {
  components: {
    HomePannel,
    HomeSkeleton
  },
  setup () {
    const goodslist = ref([])
    getHotAPI().then(data => {
    //   console.log(data)
      goodslist.value = data.result
    })

    return { goodslist }
  }
}
</script>

<style lang="less" scoped>
.goods-list{
    display: flex;
    justify-content: space-between;
    li{
        width: 306px;
        height: 406px;
        .hoverShadow();
        img{
            width: 306px;
            height: 306px;
        }
        p{
            font-size: 18px;
            text-align: center;
            padding: 10px 0 0 0;
        }
        .title{
            color: #333;
            font-size: 21px;
        }
    }
}
</style>
